<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8">
        <meta name = "viewport" content = "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv = "X-UA-Compatible" content = "ie=edge">
        <title>Test</title>
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/admin.css" rel="stylesheet">
        <script src="js/jquery-2.1.0.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <script src = "js/jquery-3.6.1.js"></script>
        
        <script src = "https://code.jquery.com/jquery-3.2.1.min.js"
                integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
                crossorigin = "anonymous">
        </script>
        <script>
      
      
        
            $(function () {
            
            	var index="${id}"
            	console.log(index)
            	if(index==1){
            		 str="<table border='1' class='table table-bordered table-hover'><tr class='success'><th>学号</th><th>姓名</th><th>性别</th><th>年龄</th><th>专业</th><th>密码</th><th>操作</tr> <c:forEach items='${list}' var='stu'><tr id='1'><td>${stu.sno}</td><td>${stu.sname}</td><td>${stu.sex}</td><td>${stu.age}</td><td>${stu.major}</td><td>${stu.password}</td><td>&nbsp;<a class='btn btn-default btn-sm' href='delectStudnetServlet?sno=${stu.sno}'>删除</a></td></tr></c:forEach></table> <tr><td width='24'></td> <table><lable>单个查询</lable><td><select name='major' class='major'><option value=''>--请选择专业--</option><option value='软工'>软工</option><option value='计科'>计科</option><option value='音舞'>音舞</option></select><spanclass='newfont06'>&nbsp姓名 :&nbsp</span><input name='name' class='name' type='text'size='10'><input name='Submit' id='selectMajor' type='button'  value='查 询'></td></tr></table>";
            		 var flag="${flag}";
            		 if(flag=='1'){
            			 alert("删除成功")
            		 }
                $(".content-right").html(str);  
            	}else if(index==2){
            		str='<div class="container" style="width: 400px;"><h3 style="text-align: center;">修改学生</h3><form action="${pageContext.request.contextPath}/UpdateServlet" method="post"><div class="form-group"><label for="name">学号：</label><input type="text" class="form-control"  name="sno"   placeholder="请输入学号" /></div><div class="form-group"><label for="name">姓名：</label><input type="text" class="form-control" id="name" name="sname"   placeholder="请输入姓名" /></div> <div class="form-group"><label for="age">年龄：</label><input type="text" class="form-control" id="age"  name="age" placeholder="请输入年龄" /><div class="form-group"><label>性别：</label><input type="radio" name="sex" value="男"  />男<input type="radio" name="sex" value="女"  />女</div><div class="form-group"><label for="qq">专业：</label><input type="text" class="form-control" name="major" placeholder="请输入专业"/></div><div class="form-group"><label for="password">密码：</label><input type="text" class="form-control" name="password" placeholder="请输入密码"/></div><div class="form-group" style="text-align: center"><input class="btn btn-primary" type="submit" value="修改" /><input class="btn btn-default" type="reset" value="重置" /></div></form></div>';
                    $(".content-right").html(str); 
                	var flag="${flag}"
                	console.log(flag);
        				if(flag=="-1"){
        					alert("修改失败")
        				}else if(flag=="1"){
        					alert("修改成功")
        				}
                    
            	}else if(index==3){
            		 str='<div class="container" style="width: 400px;"><h3 style="text-align: center;">添加学生</h3><form action="${pageContext.request.contextPath}/AddstuServlet" method="post"><div class="form-group"><label for="name">姓名：</label><input type="text" class="form-control" id="name" name="sname"   placeholder="请输入姓名" /></div><div class="form-group"><label for="age">年龄：</label><input type="text" class="form-control" id="age"  name="age" placeholder="请输入年龄" /></div><div class="form-group"><label>性别：</label><input type="radio" name="sex" value="男"  />男<input type="radio" name="sex" value="女"  />女</div><div class="form-group"><label for="qq">专业：</label><input type="text" class="form-control" name="major" placeholder="请输入专业"/></div><div class="form-group"><label for="email">密码：</label><input type="text" class="form-control" name="password" placeholder="请输入密码"/></div><div class="form-group" style="text-align: center"><input class="btn btn-primary" type="submit" value="提交" /><input class="btn btn-default" type="reset" value="重置" /><input class="btn btn-default" type="button" value="返回"/></div></form></div>';
                     $(".content-right").html(str);  
                 	var flag="${flag}"
                    	console.log(flag);
            				if(flag=="-1"){
            					alert("添加失败")
            				}else if(flag=="1"){
            					alert("添加成功")
            				}
            	}
               

                //隐藏所有子标题
                $(".nav-menu").each(function () {
                    $(this).children(".nav-content").hide();
                });

                //给菜单项中的所有主标题绑定事件
                $(".nav-title").each(function () {
                    //获取点击当前标签下所有子标签
                    var navConEle = $(this).parents(".nav-menu").children(".nav-content");

                    //绑定点击事件,判断navConEle的display这个属性是否为none,时none的话时隐藏状态
                    $(this).click(function(){
                        if (navConEle.css("display") != "none") {
                            //隐藏,传参数自带动画,单位为毫秒
                            navConEle.hide(300);
                        } else {
                            //显示,传参数自带动画,单位为毫秒
                            $(".nav-menu").each(function () {
                                $(this).children(".nav-content").hide(300);
                            });
                            navConEle.show(300);
                        }
                    });
                   $('#selectMajor').click(function(){
                	  var major= document.querySelector('.major').value;
                	  var name=document.querySelector('.name').value;
                	  location.href = "${pageContext.request.contextPath}/SearchLike?major="+major+"&name="+name; 
                      
                   })
                    
               $("#1").click(function () {
          	  location.href = "${pageContext.request.contextPath}/SelectallServlet"  
          	//  $(".content-right").html(str);  
          
          	  
          }); 
           $("#2").click(function () {
               str='<div class="container" style="width: 400px;"><h3 style="text-align: center;">修改学生</h3><form action="${pageContext.request.contextPath}/UpdateServlet" method="post"><div class="form-group"><label for="name">学号：</label><input type="text" class="form-control"  name="sno"   placeholder="请输入学号" /></div><div class="form-group"><label for="name">姓名：</label><input type="text" class="form-control" id="name" name="sname"   placeholder="请输入姓名" /></div> <div class="form-group"><label for="age">年龄：</label><input type="text" class="form-control" id="age"  name="age" placeholder="请输入年龄" /><div class="form-group"><label>性别：</label><input type="radio" name="sex" value="男"  />男<input type="radio" name="sex" value="女"  />女</div><div class="form-group"><label for="qq">专业：</label><input type="text" class="form-control" name="major" placeholder="请输入专业"/></div><div class="form-group"><label for="password">密码：</label><input type="text" class="form-control" name="password" placeholder="请输入密码"/></div><div class="form-group" style="text-align: center"><input class="btn btn-primary" type="submit" value="修改" /><input class="btn btn-default" type="reset" value="重置" /></div></form></div>';
             $(".content-right").html(str); 
			
                 });
           $("#3").click(function () {
               
               str='<div class="container" style="width: 400px;"><h3 style="text-align: center;">添加学生</h3><form action="${pageContext.request.contextPath}/AddstuServlet" method="post"><div class="form-group"><label for="name">姓名：</label><input type="text" class="form-control" id="name" name="sname"   placeholder="请输入姓名" /></div><div class="form-group"><label for="age">年龄：</label><input type="text" class="form-control" id="age"  name="age" placeholder="请输入年龄" /></div><div class="form-group"><label>性别：</label><input type="radio" name="sex" value="男"  />男<input type="radio" name="sex" value="女"  />女</div><div class="form-group"><label for="qq">专业：</label><input type="text" class="form-control" name="major" placeholder="请输入专业"/></div><div class="form-group"><label for="email">密码：</label><input type="text" class="form-control" name="password" placeholder="请输入密码"/></div><div class="form-group" style="text-align: center"><input class="btn btn-primary" type="submit" value="提交" /><input class="btn btn-default" type="reset" value="重置" /><input class="btn btn-default" type="button" value="返回"/></div></form></div>';
             $(".content-right").html(str);                      
                 });
                    
    });  
               
           
                });

         	 
            
             
              
           
                      
        </script>
<body>

        <div class = "content">
            <!--左侧导航栏-->
            <div class = "content-left">
                <div class = "left-title">
                    <a href = "#">学生信息管理 (管理员界面)</a>
                </div>

                <!--水平线-->
                <div class = "seg"></div>

                <!--菜单栏导航-->
                <div class = "nav">
                    <!--每一个菜单栏项-->
                    <div class = "nav-menu">
                        <!--主标题-->
                        <div class = "nav-title">学生管理</div>
                        <!--子标题-->
                        <div class = "nav-content">
                            <a  id="1" href="javascript:void(0);" >查询学生</a>
                            <!-- <a  id="1" href = "SelectallServlet">查询学生</a> -->
                            <a  id="3" href="javascript:void(0);">添加学生</a>
                            <a  id="2" href="javascript:void(0);">修改学生</a>  
                        </div>
                    </div>

                    <!--每一个菜单栏项-->
                    <div class = "nav-menu">
                        <!--主标题-->
                        <div class = "nav-title">学生管理</div>
                        <!--子标题-->
                        <div class = "nav-content">
                            <a href = "#">查看</a>
                            <a href = "#">排序</a>
                        </div>
                    </div>

                    <!--每一个菜单栏项-->
                    <div class = "nav-menu">
                        <!--主标题-->
                        <div class = "nav-title">学生管理</div>
                        <!--子标题-->
                        <div class = "nav-content">
                            <a href = "#">查看</a>
                            <a href = "#">删除</a>
                        </div>
                    </div>
                </div>

                <!--水平线-->
                <div class = "seg"></div>
            </div>

            <!--右侧内容区-->
            <div class = "content-right">
             
            </div>
        </div>
    </body>
</html>